package com.example.anew.journey.mynewjourney.logic.forgotPassword;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.example.anew.journey.mynewjourney.R;
import com.example.anew.journey.mynewjourney.base.BaseRegisteredAndLoginActivity;
import com.example.anew.journey.mynewjourney.logic.forgotPassword.persenter.ForgotPasswordPersenter;
import com.example.anew.journey.mynewjourney.logic.forgotPassword.view.ISForgotPasswordView;
import com.example.anew.journey.mynewjourney.logic.resetPassword.ResetPasswordActivity;

/**
 * 杭州惟君医疗科技有限公司15
 * Created by 20433 on 2018/3/5
 */

public class ForgotPasswordActivity extends BaseRegisteredAndLoginActivity implements ISForgotPasswordView {

    private TextView tv_password_introduce;
    private EditText et_phone;
    private Button bt_get_version;
    private ForgotPasswordPersenter mForgotPasswordPersenter = new ForgotPasswordPersenter(this);


    /**
     * @desc 初始化数据 onCreate()
     * */
    @Override
    protected void initView(View view) {
        // todo Toolbar的一系列操作
        setToolbarBg(0xffffffff);
        findForgotPasswordView(view);
    }

    /**
     * @desc 主要内容的布局资源填充进来
     * */
    @Override
    protected View setMainContentView() {
        return View.inflate(this, R.layout.activity_forgot_password,null);
    }

    /**===============方法区====================
     * @param view*/
    private void findForgotPasswordView(View view) {
        tv_password_introduce = (TextView) view.findViewById(R.id.activity_forgot_password_tv_password_introduce);
        et_phone = (EditText) view.findViewById(R.id.activity_forgot_password_et_phone);
        bt_get_version = (Button) view.findViewById(R.id.activity_forgot_password_bt_get_version);

        bt_get_version.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (util.check()) return;
                mForgotPasswordPersenter.onClickGetVersionCode();
            }
        });
    }
    /**
     * @desc Activity 销毁 释放资源
     */
    @Override
    protected void releaseResources() {

    }
    // 显示提示Toast信息
    @Override
    public void showToastInformation(String str) {
        Toast.makeText(this,str,Toast.LENGTH_SHORT).show();
    }
    // 获取输入的手机号
    @Override
    public String getInputPhoneNumber() {
        return et_phone.getText().toString().trim();
    }

    // 跳转到重置密码页面
    @Override
    public void toResetPasswordPager(String phoneNumber) {
        Intent intent = new Intent(ForgotPasswordActivity.this,ResetPasswordActivity.class);
        intent.putExtra("phone",phoneNumber);
        intent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT);
        startActivity(intent);
        finish();
    }


}
